package hsb.ruoyi.admin.controller;




import hsb.ruoyi.admin.mapper.UserMapper;
import hsb.ruoyi.admin.orm.User;

import javax.inject.Inject;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

@Path("/mybatis")
public class UserController {

    @Inject
    UserMapper userMapper;

//    @Inject
//    StpLogic stpLogic;

    @Path("/user/{id}")
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public User getUser(@PathParam("id") Integer id) {
//        StpUtil.login(id);
//        String tokenValueByLoginId = StpUtil.getTokenValue();
//        System.out.println(tokenValueByLoginId);
        return userMapper.getUser(id);
    }

    @Path("/user")
    @POST
    @Produces(MediaType.TEXT_PLAIN)
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    public Integer createUser(@QueryParam("id") Integer id, @QueryParam("name") String name) {
        return userMapper.createUser(id, name);
    }

    @Path("/user/{id}")
    @DELETE
    @Produces(MediaType.TEXT_PLAIN)
    public Integer removeUser(@PathParam("id") Integer id) {
        return userMapper.removeUser(id);
    }


}
